#pragma once

#include <stdint.h>
#include <stdio.h>

#include "../Common/MemoryPool.h"
#include "packet.h"
#include "heart_beat.h"
#include "authenticate.h"
#include "request.h"

class packet_manager
{
	public:
		packet_manager();
		~packet_manager(void);

		uint64_t getTotalMemUsed();
		uint64_t getTotalFreeMem();

		void print() { printf( "Total Packets: %llu\nUsed Packets: %llu\nTotal Memory: %llubytes\nFree Memory: %llubytes\nUsed Memory: %llubytes\n", total_packets, total_packets - total_free_packets, total_memory, total_memory_free, total_memory_used ); }

		packet *parse( unsigned char *buf, uint32_t length );

	private:
		MemoryPool<heart_beat, 1000, 0, boost::function<heart_beat *(void)> > *hearts;
		MemoryPool<authenticate, 1000, 0, boost::function<authenticate *(void)> > *auths;
		MemoryPool<request, 1000, 0, boost::function<request *(void)> > *reqs;

		uint64_t total_packets;
		uint64_t total_free_packets;
		uint64_t total_used_packets;
		uint64_t total_memory;
		uint64_t total_memory_used;
		uint64_t total_memory_free;
};

